package org.pangu.test.jdklistener;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangyj
 * @date 2022/7/19 22:57
 */
public class LoginSupport {

    private List<LoginListener> listenerList = new ArrayList<>();

    public void addListener(LoginListener listener) {
        this.listenerList.add(listener);
    }

    public void fireListener() {
        LoginEvent loginEvent = new LoginEvent(this);//生成事件

        for (LoginListener loginListener : listenerList) {
            loginListener.onEvent(loginEvent);
        }
    }

    //监听器回调事件源
    public void callBack() {
        System.out.println("LoginSupport callBack()");
        //统计登录
    }
}
